<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件基本使用</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <h2>欢迎，{{name}}</h2>
        <button v-on:click="showInfo">点我提示信息(传参)</button>
        <button @click="showInfo2($event,66)">点我提示信息（不传参）</button>
    </div>
</body>
    <script type="text/javascript">



        const vm = new Vue({
            el:'#root',
            data:function(){
                return{
                    name:'trentwu',
                    
                }
            },
            methods:{
                
                showInfo(event){
                    console.log(event.target.innerText);
                    console.log(this===vm)//此处this是VM
                    console.log(this)
                    alert(this.name);
                },
                showInfo2(a,number){
                    console.log(a.target.innerText);
                    console.log(this===vm)//此处this是VM
                    console.log(this)
                    alert(this.name+number);
                    console.log(a);
                }
            }
            
        })
    </script>
</html>